export {}
// 给MyReadonly<T, K>, 包含2个参数，如果k为空，则T的所有属性为readonly
// 如果设置了K参数，则只有参数的值设置readonly  Exclude v：v
type MyExclude<T, U> = T extends U ? never : T

// MyOmit 删除对象中key Omit/Pick key：value
type MyOmit<T, K extends keyof T> = {
  [key in MyExclude<keyof T, K>]: T[key]
}
// = keyof T 用于设置无值的情况，无参数则为T的所有key
type MyReadonly2<T, K extends keyof T = keyof T> = {
  readonly [key in K]: T[key]
} & {
    [key in keyof MyOmit<T, K>]: T[key]
  }

interface IPerson{
    name: string;
    age: number;
}
type person = MyReadonly2<IPerson, 'age'>
let p:person = {
    name: "John",
    age:10
}
// 无法分配到 "age" ，因为它是只读属性。
p.name = "12";
